#ifndef DRAW
#define DRAW

#include "fbo.h"
#include "texture.h"
#include "../core/device/device.h"
#include "../mesh/material.h"
#include "../mesh/geometry.h"

namespace sleek
{
    namespace core
    {
        namespace device
        {
            class Device;
        }
    }
    namespace texture
    {
        class draw// : public  btIDebugDraw
        {
            public:
                draw(core::device::Device*);
                ~draw();

                void drawPixel(core::math::vector2di, pixel c = pixel());
                void drawPixel(core::math::vector3df, pixel c = pixel());
                void drawLine(core::math::vector2di, core::math::vector2di, pixel c = pixel());
                void drawLine(core::math::vector3df, core::math::vector3df, pixel c = pixel());
                void drawArc(core::math::vector2di, core::u32, core::u32, core::u32, pixel c = pixel());

                void drawCube(core::math::aabbox2di, core::math::vector3df rot = core::math::vector3df(0), pixel c = pixel());
                void drawCube(core::math::aabbox3df, core::math::vector3df rot = core::math::vector3df(0), pixel c = pixel());
                void drawCube(core::math::vector2di, core::math::vector2di, core::math::vector3df rot = core::math::vector3df(0), pixel c = pixel());
                void drawCube(core::math::vector3df, core::math::vector3df, core::math::vector3df rot = core::math::vector3df(0), pixel c = pixel());

                void drawCircle(core::math::vector2di pos, core::u32 radius = 5.f, pixel c = pixel());

                void drawPolygon(core::math::vector2di, core::math::vector2di, core::math::vector2di, pixel c = pixel());
                void drawPolygon(core::math::vector3df, core::math::vector3df, core::math::vector3df, pixel c = pixel());
                void drawPolygonList(core::math::vector2di *a, core::u32 n, core::math::vector2di, core::math::vector3df rot = core::math::vector3df(0), pixel c = pixel());
                void drawPolygonList(core::math::vector3df *a, core::u32 n, core::math::vector3df, core::math::vector3df rot = core::math::vector3df(0), pixel c = pixel());

                void drawRoundedCube(core::math::aabbox2di, core::u32 radius = 5.f, pixel c = pixel());
                void drawRoundedCube(core::math::vector2di, core::math::vector2di, core::u32 radius = 5.f, pixel c = pixel());

                void drawFBO(fbo*);

                void drawTexture(texture*, core::math::vector2di pos = core::math::vector2di(0,0), core::math::vector3df rot = core::math::vector3df(0,0,0), core::math::vector2df scale = core::math::vector2df(1,1));
                void drawTexture(texture*, core::math::vector3df pos = core::math::vector3df(0,0,0), core::math::vector3df rot = core::math::vector3df(0,0,0), core::math::vector2df scale = core::math::vector2df(1,1));
                void drawTextureCenter(texture*, core::math::vector2di pos = core::math::vector2di(0,0), core::math::vector3df rot = core::math::vector3df(0,0,0), core::math::vector2df scale = core::math::vector2df(1,1));
                void drawTextureCenter(texture*, core::math::vector3df pos = core::math::vector3df(0,0,0), core::math::vector3df rot = core::math::vector3df(0,0,0), core::math::vector2df scale = core::math::vector2df(1,1));

                void drawMesh(mesh::MeshBuffer*, core::math::vector3df, core::math::vector3df rot = core::math::vector3df(0));

                void setActiveMaterial(mesh::material*);
                mesh::material* getActiveMaterial();

                virtual void ObjectRenderBegin();
                virtual void ObjectRenderEnd();

                virtual void beginTo2D();
                virtual void endFrom2D();
            protected:
                GLuint quad, quadc, cubec; //display list (quad and point render accelerator)
            private:
                core::device::Device *src;
                mesh::material *mat;
                texture *cnv;
                core::u32 tricounter;
        };
    }
}

#endif
